package org.mm.model;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;


/**
 * The persistent class for the patients database table.
 *
 */
@Entity
@Table(name="patients")
public class Patient implements Serializable {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = -2800548324018045769L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="patient_id")
	private Long patientId;

	@Temporal(TemporalType.DATE)
	@Column(name="patient_birth_date")
	private Date patientBirthDate;

	@Column(name="patient_creation_date")
	private Timestamp patientCreationDate;

	@Column(name="patient_last_modification_date")
	private Timestamp patientLastModificationDate;

	@Column(name="patient_medical_record")
	private String patientMedicalRecord;

	@Version
	@Column(name="patient_version")
	private int patientVersion;

	//bi-directional many-to-one association to Drug
/*	@OneToMany(mappedBy="patient", fetch=FetchType.EAGER)
	private List<Drug> drugs;*/

	//bi-directional many-to-one association to Measurement
/*	@OneToMany(mappedBy="patient", fetch=FetchType.EAGER)
	private List<Measurement> measurements;*/

	//bi-directional many-to-one association to Doctor
/*	@ManyToOne
	@JoinColumn(name="patient_doctor_id")
	private Doctor doctor;*/

	//bi-directional many-to-one association to User
	@ManyToOne
	@JoinColumn(name="patient_parent_user_id")
	private User user1;

	//bi-directional many-to-one association to User
	@ManyToOne
	@JoinColumn(name="patient_created_by_user")
	private User user2;

	//bi-directional many-to-one association to User
	@ManyToOne
	@JoinColumn(name="patient_last_modified_by_user")
	private User user3;

	//bi-directional many-to-one association to Sensor
/*	@OneToMany(mappedBy="patient", fetch=FetchType.LAZY)
	private List<Sensor> sensors;*/

	public Patient() {
	}

	public Long getPatientId() {
		return this.patientId;
	}

	public void setPatientId(Long patientId) {
		this.patientId = patientId;
	}

	public Date getPatientBirthDate() {
		return this.patientBirthDate;
	}

	public void setPatientBirthDate(Date patientBirthDate) {
		this.patientBirthDate = patientBirthDate;
	}

	public Timestamp getPatientCreationDate() {
		return this.patientCreationDate;
	}

	public void setPatientCreationDate(Timestamp patientCreationDate) {
		this.patientCreationDate = patientCreationDate;
	}

	public Timestamp getPatientLastModificationDate() {
		return this.patientLastModificationDate;
	}

	public void setPatientLastModificationDate(Timestamp patientLastModificationDate) {
		this.patientLastModificationDate = patientLastModificationDate;
	}

	public String getPatientMedicalRecord() {
		return this.patientMedicalRecord;
	}

	public void setPatientMedicalRecord(String patientMedicalRecord) {
		this.patientMedicalRecord = patientMedicalRecord;
	}

	public int getPatientVersion() {
		return this.patientVersion;
	}

	public void setPatientVersion(int patientVersion) {
		this.patientVersion = patientVersion;
	}

	/*public List<Drug> getDrugs() {
		return this.drugs;
	}

	public void setDrugs(List<Drug> drugs) {
		this.drugs = drugs;
	}

	public Drug addDrug(Drug drug) {
		getDrugs().add(drug);
		drug.setPatient(this);

		return drug;
	}*/

/*	public Drug removeDrug(Drug drug) {
		getDrugs().remove(drug);
		drug.setPatient(null);

		return drug;
	}

	public List<Measurement> getMeasurements() {
		return this.measurements;
	}

	public void setMeasurements(List<Measurement> measurements) {
		this.measurements = measurements;
	}

	public Measurement addMeasurement(Measurement measurement) {
		getMeasurements().add(measurement);
		measurement.setPatient(this);

		return measurement;
	}

	public Measurement removeMeasurement(Measurement measurement) {
		getMeasurements().remove(measurement);
		measurement.setPatient(null);

		return measurement;
	}

	public Doctor getDoctor() {
		return this.doctor;
	}

	public void setDoctor(Doctor doctor) {
		this.doctor = doctor;
	}*/

	public User getUser1() {
		return this.user1;
	}

	public void setUser1(User user1) {
		this.user1 = user1;
	}

	public User getUser2() {
		return this.user2;
	}

	public void setUser2(User user2) {
		this.user2 = user2;
	}

	public User getUser3() {
		return this.user3;
	}

	public void setUser3(User user3) {
		this.user3 = user3;
	}

/*	public List<Sensor> getSensors() {
		return this.sensors;
	}

	public void setSensors(List<Sensor> sensors) {
		this.sensors = sensors;
	}*/

/*	public Sensor addSensor(Sensor sensor) {
		getSensors().add(sensor);
		sensor.setPatient(this);

		return sensor;
	}

	public Sensor removeSensor(Sensor sensor) {
		getSensors().remove(sensor);
		sensor.setPatient(null);

		return sensor;
	}*/

}